import request from "@/utils/request";
import type {
  GetTrademarkListResponse,
  TrademarkList,
} from "./model/trademarkModel";

enum Api {
  getTrademarkListUrl = "/admin/product/baseTrademark",
  getAllTrademarkListUrl = "/admin/product/baseTrademark/getTrademarkList",
  addTrademarkUrl = "/admin/product/baseTrademark/save",
  deleTrademarkListUrl = "/admin/product/baseTrademark/remove",
  updateTrademarkListUrl = "/admin/product/baseTrademark/update",
}

export const getTrademarkListApi = (page: number, limit: number) => {
  return request.get<any, GetTrademarkListResponse>(
    Api.getTrademarkListUrl + `/${page}/${limit}`
  );
};

/**
 * 获取所有品牌列表数据
 * @returns TrademarkList
 */
export const getAllTrademarkListApi = () => {
  return request.get<any, TrademarkList>(Api.getAllTrademarkListUrl);
};

// 添加品牌接口函数
export const addTrademarkFormApi = (tmName: string, logoUrl: string) => {
  return request.post<any, null>(Api.addTrademarkUrl, { tmName, logoUrl });
};
//删除接口函数
export const delTrademarkListApi = (id: number) => {
  return request.delete<any, number>(Api.deleTrademarkListUrl + `/${id}`);
};
//修改的接口函数
export const UpdateTrademarkListApi = (
  id: number,
  tmName: string,
  logoUrl: string
) => {
  return request.put<any, null>(Api.updateTrademarkListUrl, {
    id,
    tmName,
    logoUrl,
  });
};
